<!--
 * @Author: your name
 * @Date: 2021-06-18 11:45:22
 * @LastEditTime: 2021-06-18 16:05:48
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \agriculture-ui\src\pages\cms\Category.vue
-->
<template>
    <div>
        栏目管理
        <h2>{{title}}</h2>
     <el-table :data="categories" style="width: 100%">
     <el-table-column prop="name" label="名称"> </el-table-column>
     <el-table-column prop="description" label="项目" width="200" align="center"> </el-table-column>
     <el-table-column prop="id" label="序号" width="200"> </el-table-column>
     <el-table-column label="操作" width="200" align="center">
     <template v-slot="scope">
     <el-button @click="delHandler(scope.row)" type="text" size="small">删除</el-button>
     </template>
     </el-table-column>
     </el-table>
    </div>
</template>
<script>
import {get,post} from '@/utils/request'
export default {
    data(){
        return{
            title:"栏目管理",
            categories:[]
        }
    },
    methods:{
        delHandler(row){this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
             confirmButtonText: '确定',
             cancelButtonText: '取消',
             type: 'warning'
            }).then(() => {
                let url="/category/batchDelete"
                get(url,{id:row.id}).then(resp=>{
                //提示删除成功
                this.$message({type:"success",message:resp.message})
                //刷新页面
                this.loadData()
            });
            })
        },
        loadData(){
            let url = "/category/findAll";
            get(url).then( resp => {
                this.categories = resp.data;
            });
        }
    },
    created(){
        this.loadData();
    }
}
</script>